#include<iostream>
#include<unistd.h>
#include"SetNoBlock.hpp"

int main()
{
    SetNoBlock(0);
    char buffer[1024];
    while(true)
    {
        ssize_t n = ::read(0,&buffer,sizeof(buffer) - 1);
        if(n > 0)
        {
            buffer[n] = 0;
            std::cout<<"echo#: "<<buffer<<std::endl;
        }
        else 
        {
            if(errno == EAGAIN || errno ==EWOULDBLOCK)
            {
                std::cout<<"读取条件未就绪,下次再试试吧！"<<std::endl;
                sleep(1);
                continue;
            }
            std::cout<<"读取错误! "<<std::endl;
        }
        sleep(1);
    }
    return 0;
}